package com.ktjiaoyu.crm.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ktjiaoyu.crm.pojo.User;
import com.ktjiaoyu.crm.service.UserService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @ClassName : UserController
 * @Description :
 * @Author : Lzz
 * @Date: 2023/11/17 09:03:59
 */
@Controller
public class UserController {

    @Resource
    UserService userService;

    @RequestMapping(value = "/getUser",method = RequestMethod.GET)
    @ResponseBody
    public User getUser(){
        QueryWrapper wrapper = new QueryWrapper();
        wrapper.eq("usr_id", 1);
        return userService.getOne(wrapper);
    }

    @GetMapping(value = "/users")
    public List<User> findAllUsers(){
        List<User> list = userService.list();
        return list;
    }

    @GetMapping(value = "/user/{id}")
    @ResponseBody
    public User getUser(@PathVariable("id")Long usrId){
        User user = userService.getById(usrId);
        return user;
    }



}
